package com.haoyeteng.sxbd.modular.business.controller;

import com.haoyeteng.sxbd.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.haoyeteng.sxbd.core.base.model.ResponseResult;
import com.haoyeteng.sxbd.core.common.annotion.Permission;
import java.util.List;
import java.util.Map;
import com.haoyeteng.sxbd.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.haoyeteng.sxbd.modular.business.model.OrderDtl;
import com.haoyeteng.sxbd.modular.business.service.IOrderDtlService;

/**
 * 订单明细表控制器
 *
 * @author haoyeteng
 * @Date 2019-06-27 00:45:59
 */
@Controller
@RequestMapping("/orderDtl")
public class OrderDtlController extends BaseController {

    private String PREFIX = "/business/orderDtl/";

    @Autowired
    private IOrderDtlService orderDtlService;

    /**
     * 跳转到订单明细表首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "orderDtl.html";
    }

    /**
     * 跳转到添加订单明细表
     */
    @RequestMapping("/orderDtl_add")
    public String orderDtlAdd() {
        return PREFIX + "orderDtl_add.html";
    }

    /**
     * 跳转到修改订单明细表
     */
    @RequestMapping("/orderDtl_update/{orderDtlId}")
    public String orderDtlUpdate(@PathVariable Integer orderDtlId, Model model) {
        OrderDtl orderDtl = orderDtlService.selectById(orderDtlId);
        model.addAttribute("item",orderDtl);
        LogObjectHolder.me().set(orderDtl);
        return PREFIX + "orderDtl_edit.html";
    }

    /**
     * 获取订单明细表列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    @Permission
    public ResponseResult<Object> list(String condition) {
    	ResponseResult<Object> result = new ResponseResult<Object>();
        result.setData(0);
 		result.setCount(0);
     	result.setCode(SUCCESS_TIP.getCode());
     	result.setMsg(SUCCESS_TIP.getMessage());
 		return result;
    }

    /**
     * 新增订单明细表
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    @Permission
    public Object add(OrderDtl orderDtl) {
        orderDtlService.insert(orderDtl);
        return SUCCESS_TIP;
    }

    /**
     * 删除订单明细表
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    @Permission
    public Object delete(@RequestParam Integer orderDtlId) {
        orderDtlService.deleteById(orderDtlId);
        return SUCCESS_TIP;
    }

    /**
     * 修改订单明细表
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    @Permission
    public Object update(OrderDtl orderDtl) {
        orderDtlService.updateById(orderDtl);
        return SUCCESS_TIP;
    }

    /**
     * 订单明细表详情
     */
    @RequestMapping(value = "/detail/{orderDtlId}")
    @ResponseBody
    public Object detail(@PathVariable("orderDtlId") Integer orderDtlId) {
        return orderDtlService.selectById(orderDtlId);
    }
}
